package cn.cnsy123.blog.application.util;

import org.apache.commons.codec.digest.Md5Crypt;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;

/**
 * @author yangpengfei
 * @description 密码处理
 * @date 2019-10-15 16-41-22
 */
public class PassWordUtil {

    private static final String CHAR_PASS = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789";

    private static final int CHAR_LEN = 12;

    public static String generatePassSalt(int length){
        if (length == 0){
            throw new IllegalArgumentException("生成密码盐-混淆部分，参数不能为0");
        }

        return RandomStringUtils.random(length,CHAR_PASS);
    }

    public static String generatePassSalt(){
        return RandomStringUtils.random(CHAR_LEN,CHAR_PASS);
    }

}
